package com.djinfo.work.activiti.dao.impl;

import com.djinfo.work.activiti.dao.PermissionDao;
import com.djinfo.work.activiti.po.Permission;
import com.djinfo.work.activiti.po.Role_permission;
import com.djinfo.work.common.dao.impl.BaseDaoImpl;
import org.hibernate.SQLQuery;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 请假
 */
@Repository("PermissionDao")
public class PermissionDaoImpl extends BaseDaoImpl implements PermissionDao{


	@Override
	public void addpermission(String permissionname) {

	}

	@Override
	public List<Permission> getallPermission() {
		return this.loadAll(Permission.class);
	}

	@Override
	public void delRole_permission(String pid) {
		String sql ="delete from role_permission where permissionid='"+pid+"'";
		SQLQuery sQLQuery = this.getSessionFactory().getCurrentSession().createSQLQuery(sql.toString());
		sQLQuery.executeUpdate();
	}

	@Override
	public void delpermission(Permission permission) {
		this.delete(permission);
	}

	@Override
	public Permission getpermissionbypermissionname(String permissionname) {
		return this.findUniqueByProperty(Permission.class,"permissionname",permissionname);
	}

	@Override
	public void addrole_permission(Role_permission role_permission) {
		this.save(role_permission);
	}

	@Override
	public Permission getpermissionbyid(String pid) {
		return this.findUniqueByProperty(Permission.class,"pid",pid);
	}

	@Override
	public Role_permission getrolepermissionbyid(String pid) {
		return this.findUniqueByProperty(Role_permission.class,"permissionid",pid);
	}

	@Override
	public void addpermi(Permission permission) {
		this.save(permission);
	}


}
